<?php
	/*
	** Your code here
	*/
	$g_func = new global_function();
	$exe_mysql = new execute_mysql_query();
	$result = $exe_mysql->execute("select * from category", 0);
	
	@$cat = $_GET['cat']; //Get category id from URL
	@$idcat = str_replace('-','',$cat);
	//echo 'Products';
	//print $idcat;
	
function cut($str, $len) {
    $str = trim($str);
    if (strlen($str) <= $len) return $str;
    $str = substr($str, 0, $len);
    if ($str != "") {
        if (!substr_count($str, " ")) return $str." ...";
        while (strlen($str) && ($str[strlen($str) - 1] != " ")) $str = substr($str, 0, -1);
        $str = substr($str, 0, -1)." ...";
    }
    return $str;
}	
?>
<link rel="stylesheet" href="css/text_css_hqk.css" type="text/css" />


<div class="main_category">
<!--
<div class="menu_pr">
<div class="head_menu_cat">Danh mục sản phẩm</div>
<div class="line"></div>
<ul class="list_menu">

<?php
/*while($row = mysql_fetch_array($result))
{
	echo '<li><a href="san-pham-'.$row['id'].'.html">'.$row['name'].'</a></li>';
}*/
//-----Tinh toan phan trang------------------------------------------------------------------------------------
@$cur_page  = str_replace('-','',$_GET['page']);
$ROWS_PER_PAGE = 10;
$total_record = $exe_mysql->execute("select id from node where id_type = 3 and id_ref = $idcat", 2);
$begin = $g_func->get_begin($cur_page, $ROWS_PER_PAGE, $total_record);

?>
</ul>
</div>-->
<?php
//include_once($include_cat);
if($idcat == "")
{
	$result2 = $exe_mysql->execute("select * from node where id_type = 3 order by id desc limit 10", 0);
	while($row2 = mysql_fetch_array($result2))
	{
		
		echo '<div class="list_sub_cat">';
		echo '<div class="hinh"><a href="chi-tiet-san-pham-'.$row2['id_ref'].'-'.$g_func->remove_sign($row2['title_'.$LOCAL]).'-'.$row2['id'].'.html" ><img src="'.$row2['img'].'" width="150px" height="120px" border="0px" alt="'.$row2['title_'.$LOCAL].'" title="'.$row2['title_'.$LOCAL].'" /></a></div>';
		echo '<div class="xem_tiep"><a href="chi-tiet-san-pham-'.$row2['id_ref'].'-'.$g_func->remove_sign($row2['title_'.$LOCAL]).'-'.$row2['id'].'.html" >'.cut($row2['title_'.$LOCAL],26).'</a></div>';
		echo '</div>';
	}
}
else
{
	$result2 = $exe_mysql->execute("select * from node where id_type = 3 and id_ref = $idcat order by id desc limit $begin, $ROWS_PER_PAGE", 0);
	while($row2 = mysql_fetch_array($result2))
	{
		echo '<div class="list_sub_cat">';
		echo '<div class="hinh"><a href="chi-tiet-san-pham-'.$row2['id_ref'].'-'.$g_func->remove_sign($row2['title_'.$LOCAL]).'-'.$row2['id'].'.html" ><img src="'.$row2['img'].'" width="150px" height="120px" border="0px" alt="'.$row2['title_'.$LOCAL].'" title="'.$row2['title_'.$LOCAL].'" /></a></div>';
		echo '<div class="xem_tiep"><a href="chi-tiet-san-pham-'.$row2['id_ref'].'-'.$g_func->remove_sign($row2['title_'.$LOCAL]).'-'.$row2['id'].'.html" >'.cut($row2['title_'.$LOCAL],26).'</a></div>';
		echo '</div>';
	}
	//-----Insert phan trang-----------------------------------------------------------
	//$g_func->paging($total_record, $ROWS_PER_PAGE);
}
?>
</div> 
<div class="phan_trang">
<?php
$g_func->paging($total_record, $ROWS_PER_PAGE);
?>
</div>

















